﻿using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using Rison.DataAccess.Data.ZJCP;
using System.Text;
using System.Web.SessionState;

namespace Rison.Web.ZJCP.ashx
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class load_experts : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write(String.Format("var _experts=[{0}]", findAllExperts()));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
        private string findAllExperts()
        {
            string sql = "select ex_id,ex_true_name from expert where ex_is_expert = '1' order by ex_id";
            DataSet ds = DbAccess.executeQuery(sql);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (i > 0)
                {
                    sb.Append(",");
                }
                sb.AppendFormat("{{exId:\"{0}\",exTrueName:\"{1}\"}}", ds.Tables[0].Rows[i][0], ds.Tables[0].Rows[i][1]);
            }
            return sb.ToString();
        }
    }
}
